<template>
  <div class="comment">
    <magic-header titleName="评论">
      <div :class="!isSilent&&content?'submit-btn':'cant-btn'" slot="title-right" v-tap="{methods:submitComment}">
        发送
      </div>
    </magic-header>
    <div class="content">
      <textarea v-model="content" placeholder="说点什么吧" maxlength="50"></textarea>
    </div>
  </div>
</template>
<script>
import magicHeader from "components/magicHeader";
import CreateSpaceCommentService from "services/community/CreateSpaceComment";
import QueryStore from "services/community/QueryStore";
export default {
  name: "comment",
  data() {
    return {
      id: "",
      content: "",
      isSilent:false
    };
  }, 
  components: { magicHeader },
  methods: {
    getcommunitySilent(){
      QueryStore.bind(this)({

      },resp=>{
        console.log(resp.shop.communitySilent)
        this.isSilent = resp.shop.communitySilent === '1'? true : false
      })
    },
    submitComment() {
      if(this.isSilent){
        this.$.toast('您已被禁言')
        return
      }
      CreateSpaceCommentService.bind(this)(
        {
          content: this.content,
          spaceId: this.id
        },
        resp => {
          this.$router.back();
        }
      );
    }
  },
  created() {
    this.id = this.$route.params.id;
    console.log(this.$route);
    this.getcommunitySilent()
  }
};
</script>

<style scoped>
.comment {
  height: 100%;
  background: #fff;
}
textarea {
  padding: 10px;
  font-size: 16px;
  line-height: 24px;
  border: none;
  resize: none;
  outline: none;
  width: calc(100% - 20px);
  height: calc(100vh - 74px);
}
textarea.active {
  border: none;
}
textarea.focus {
  border: none;
}
</style>